package com.example.graduate.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import com.example.graduate.dto.AddOrderRequest;
import com.example.graduate.env.OrderStatusEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 订单表
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Order {
    /**
     * 主键
     */
    private Long Id;

    /**
     * 发单者Id
     */
    private Long userId;

    /**
     * 任务Id
     */
    private Long taskId;

    /**
     * 订单类型
     */

    private String orderType;

    /**
     * 订单状态
     */
    private String orderStatus;

    /**
     * 订单创建时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 订单最晚接单时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date acceptTime;

    /**
     * 订单最晚送达时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date lastDeliverTime;

    /**
     * 订单结束时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date finishTime;

    /**
     * 接单者Id
     */
    private Long advisersId;

    /**
     * 接单时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date adviseTime;

    public Order(AddOrderRequest addOrderRequest,Long taskId){
        this.userId = addOrderRequest.getUserId();
        this.orderStatus = OrderStatusEnum.RUNNABLE.getCode();
        this.taskId = taskId;
        this.orderType = addOrderRequest.getOrderType();
        this.acceptTime = addOrderRequest.getAcceptTime();
        this.lastDeliverTime = addOrderRequest.getLastDeliverTime();
    }
}
